package com.kaibo.roomdemo.data.db.entity

import android.arch.persistence.room.*
import com.kaibo.roomdemo.annotation.PoKo

/**
 * @author Administrator
 * @date 2018/2/7 0007 下午 3:01
 * GitHub：
 * email：
 * description：
 */

@PoKo
@Entity(
        tableName = "books",
        foreignKeys = [ForeignKey(entity = UserEntity::class, parentColumns = ["id"], childColumns = ["user_id"])],
        indices = [(Index("user_id"))]
)
data class BookEntity(

        @PrimaryKey(autoGenerate = true)
        @ColumnInfo(name = "id")
        var id: Long = 0,

        @ColumnInfo(name = "book_name")
        var bookName: String = "",

        @ColumnInfo(name = "book_price")
        var bookPrice: Double = 0.0,

        @ColumnInfo(name = "book_page")
        var bookPage: Int = 0,

        //外键  ----->   指向 user  表的主键
        @ColumnInfo(name = "user_id")
        var userId: Long = 0,

        @ColumnInfo(name = "is_read")
        var isRead: Boolean = false
)